package com.hxzy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.common.core.domain.entity.PzServiceItem;
import com.hxzy.common.core.domain.entity.SysDictData;
import com.hxzy.common.core.domain.entity.SysUser;
import com.hxzy.common.exception.ServiceException;
import com.hxzy.system.domain.dto.PzServiceItemDTO;
import com.hxzy.system.mapper.PzServiceItemMapper;
import com.hxzy.system.mapper.SysDictDataMapper;
import com.hxzy.system.service.ISysUserService;
import com.hxzy.system.service.PzServiceItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class PzServiceItemServicelmpl extends ServiceImpl<PzServiceItemMapper, PzServiceItem> implements PzServiceItemService {


    @Autowired
    private SysDictDataMapper sysDictDataMapper;


    @Override
    public IPage<PzServiceItem> search(PzServiceItemDTO pzServiceItemDTO) {
        IPage<PzServiceItem> page = new PageDTO(pzServiceItemDTO.getPageNum(), pzServiceItemDTO.getPageSize());
        return this.baseMapper.search(page, pzServiceItemDTO);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public boolean deleteByIds(Long[] ids) {
        boolean update=false;
        for (Long id:ids){
            LambdaUpdateWrapper<PzServiceItem> updateWrapper= new LambdaUpdateWrapper<>();
            updateWrapper.set(PzServiceItem::getDelFlag,2).eq(PzServiceItem::getId,id);
            update = update(updateWrapper);
        }
        return update;
    }

    
    @Override
    public List<SysDictData> approveItemNameList() {
        return this.sysDictDataMapper.approveItemNameList();
    }

    @Override
    public List<SysDictData> serviceTypeIdList() {
        return this.sysDictDataMapper.serviceTypeIdList();
    }

    @Override
    public List<SysDictData> consigorList() {
        return this.sysDictDataMapper.consigorList();
    }

    @Override
    public List<SysDictData> certificateGradeList() {
        return this.sysDictDataMapper.certificateGradeList();
    }

    @Override
    public List<SysDictData> delegateTypeIdList() {
        return this.sysDictDataMapper.delegateTypeIdList();
    }

    @Override
    public List<SysDictData> serviceChargeList() {
        return this.sysDictDataMapper.serviceChargeList();
    }

    @Override
    public List<SysDictData> paymentList() {
        return this.sysDictDataMapper.paymentList();
    }

    @Override
    public IPage<PzServiceItem> searchOfFront(PzServiceItemDTO pzServiceItemDTO) {
        IPage<PzServiceItem> page = new PageDTO(pzServiceItemDTO.getPageNum(), pzServiceItemDTO.getPageSize());
        return this.baseMapper.searchOfFront(page, pzServiceItemDTO);
    }

    @Override
    public PzServiceItem getInfo(Long id) {
        return this.baseMapper.getInfo(id);
    }

    /**
     * 中介服务 新增数据
     * @param pzServiceItem
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int add(PzServiceItem pzServiceItem) {
        return this.baseMapper.add(pzServiceItem);
    }

    @Override
    public int selectByApproveItemCodeUnique(String approveItemCode) {
        return this.baseMapper.selectByApproveItemCodeUnique(approveItemCode);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int updateByPzId(PzServiceItem pzServiceItem) {
        return this.baseMapper.updateByPzId(pzServiceItem);
    }

}
